package net.csdn.business.auth.feign;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.csdn.business.common.annotation.Inner;
import net.csdn.business.common.domain.request.oauth.GatewayRouteInfoQuery;
import net.csdn.business.common.domain.request.oauth.NewGatewayRouteInfoDTO;
import net.csdn.business.common.domain.request.oauth.UpdateGatewayRouteInfoDTO;
import net.csdn.business.common.domain.vo.oauth.GatewayRouteInfoVO;
import net.csdn.business.common.oauth2.service.IGatewayRouteInfoService;
import org.springframework.web.bind.annotation.*;


/**
 * @Desc: GatewayRouteController
 * @ClassName: TokenController
 * @Author: yourleige@163.com
 * @Date: 2022/9/27 11:16
 */
@Slf4j
@Inner
@RestController
@RequestMapping("/api/v1/route")
@RequiredArgsConstructor
public class AuthGatewayRouteController
{
    private final IGatewayRouteInfoService gatewayRouteInfoService;


    /**
     * 分页查询网关路由信息
     *
     * @param query 网关路由信息详细信息
     * @return 网关路由信息
     */
    @PostMapping("/list")
    public Page<GatewayRouteInfoVO> findPageList(@RequestBody GatewayRouteInfoQuery query){
        return gatewayRouteInfoService.findPageList(query);
    }


    /**
     * 根据id查询网关路由信息详细信息
     *
     * @param id 网关路由信息主键
     * @return 网关路由信息
     */
    @GetMapping("/{id}")
    public GatewayRouteInfoVO getById(@PathVariable("id") Long id){
        return gatewayRouteInfoService.getById(id);
    }


    /**
     * 新增网关路由信息
     *
     * @param params 网关路由信息
     * @return 结果
     */
    @PostMapping("/add")
    public Integer addGatewayRoute(@RequestBody NewGatewayRouteInfoDTO params){
        return gatewayRouteInfoService.addGatewayRoute(params);
    }

    /**
     * 修改网关路由信息
     *
     * @param params 网关路由信息
     * @return 结果
     */
    @PostMapping("/update")
    public Integer updateGatewayRoute(@RequestBody UpdateGatewayRouteInfoDTO params){
        return gatewayRouteInfoService.updateGatewayRoute(params);
    }



    /**
     * 根据id删除网关路由信息信息
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Integer deleteGatewayRoute(@PathVariable("id") Long id){
        return gatewayRouteInfoService.deleteGatewayRoute(id);
    }


}
